using System;
using System.Web;

using MetaSapiens.PageMethods;

namespace WebApplication
{
  public class HttpHandler : IHttpHandler
  {
    HttpContext _context;

    public void ProcessRequest(HttpContext context)
    {
      _context = context;
      if (!PageMethodsEngine.InvokeMethod(this, true))
        throw new Exception("Page method not found!");
    }

    public bool IsReusable
    {
      get { return false; }
    }
    
    [PageMethod(true)]
    public void SampleMethod(int i)
    {
      _context.Response.ContentType = "text/plain";
      _context.Response.Write("Hello from HTTP handler.\nSampleMethod("+i+")");
    }
  }
}